<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div id="zxy_pc_panel" class="easyui-panel"></div>
	<div style="padding:10px">
		<a id="zxy_pc_back" class="easyui-linkbutton" href="javascript:void(0)">上一步</a>
		<a id="zxy_pc_next" class="easyui-linkbutton" href="javascript:void(0)">下一步</a>
		<a id="zxy_pc_submit" class="easyui-linkbutton" href="javascript:void(0)">提交</a>
	</div>
	<script>
		$("#zxy_pc_panel").panel({
			width:'100%',
			height:'90%',
			title:'选择员工',
			href:'../emp/selectEmp',
		});
		//选择好员工后进入下一步，找到员工的基本信息
		$("#zxy_pc_next").linkbutton({
			onClick:function(){
				if($("#zxy_pcel_dg").datagrid("getChecked").length!=1){
					return;
				}	
				var row=$("#zxy_pcel_dg").datagrid("getChecked")[0];
				$("#zxy_pc_panel").panel('refresh','../personnelChange/positionChange?empId='+row.empId);
				$("#zxy_pc_next").linkbutton('disable');
				$("#zxy_pc_back").linkbutton('enable');
				$("#zxy_pc_submit").linkbutton('enable');
			}
		});

		$("#zxy_pc_back").linkbutton({
			disabled:true,
			onClick:function(){
				$("#zxy_pc_panel").panel('refresh','../emp/selectEmp');
				$("#zxy_pc_back").linkbutton('disable');
				$("#zxy_pc_next").linkbutton('enable');
			}
		});
		$("#zxy_pc_submit").linkbutton({
			disabled:true,
			onClick:function(){
				var empId=$("#zxy_pc_emp_id").text();
				var newDep=$("#zxy_pc_dep").textbox('getValue');
				var newPost=$("#zxy_pc_post").combobox('getValue');
				var newRank=$("#zxy_pc_rank").combobox('getValue');
				if(newPost==''&&newDep==''&&newRank==''){
					$.messager.alert('错误','变动内容为空');
					return;
				}
				var approver=$("#zxy_pc_approver").combobox('getValue');
				var approverDep=$("#zxy_pc_approver_dep").textbox('getText');
				if(approver==''){
					$.messager.alert('错误','必须选择审批者');
					return;
				}
				var docNum=$("#zxy_pc_doc_num").textbox('getText');
				var remark=$("#zxy_pc_remark").textbox('getText');
				console.log(newDep+"-"+newPost+"-"+newRank+"-"+approver+"-"+approverDep+"-"+docNum+"-"+remark);
				$.ajax({
					url:'../personnel/addPositionChange',
					type:'post',
					data:{
						empId:empId,
						newDep:newDep,
						newPost:newPost,
						newRank:newRank,
						approver:approver,
						approverDep:approverDep,
						docNum:docNum,
						remark:remark
					},
					success:function(data){
						if(data.success){
							$.messager.alert('操作成功',data.message);
							$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
						}else{
							$.messager.alert('操作失败',data.message);
						}
					}
				})
			}
		});
	</script>
</body>
</html>